//
//  XBAudioUnitRecorder.h
//  XBVoiceTool
//
//  Created by xxb on 2018/6/28.
//  Copyright © 2018年 xxb. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Header_audio.h"

#define mp3StroePath [NSHomeDirectory() stringByAppendingString:@"/Documents/QKDExamLabRecorder.mp3"]
#define LEVEL_LOWPASS_TRIG .3

typedef void(^XBAudioUnitRecorderPeakPowerBlock)(NSNumber *);

// 0 - 失败 1 - 成功 2 - 录音过短 3 - 上传失败
typedef void(^XBAudioUnitRecorderUploaderCompleteBlock)(NSString *url, NSInteger result);

@class XBAudioUnitRecorder;

typedef void (^XBAudioUnitRecorderOnputBlock)(AudioBufferList *bufferList);
typedef void (^XBAudioUnitRecorderOnputBlockFull)(XBAudioUnitRecorder *player,
                                                AudioUnitRenderActionFlags *ioActionFlags,
                                                const AudioTimeStamp *inTimeStamp,
                                                UInt32 inBusNumber,
                                                UInt32 inNumberFrames,
                                                AudioBufferList *ioData,
                                                float peakPower
                                                  );

@interface XBAudioUnitRecorder : NSObject
@property (nonatomic,readonly,assign) BOOL isRecording;
@property (nonatomic,copy) XBAudioUnitRecorderOnputBlock bl_output;
@property (nonatomic,copy) XBAudioUnitRecorderOnputBlockFull bl_outputFull;
/// 上传完成
@property(nonatomic,copy) XBAudioUnitRecorderUploaderCompleteBlock bl_uploaderComplete;


- (instancetype)initWithRate:(XBAudioRate)rate bit:(XBAudioBit)bit channel:(XBAudioChannel)channel;
- (void)start;
- (void)stop;
-(void)destory;
- (AudioStreamBasicDescription)getOutputFormat;
@end
